﻿<Window x:Class="MicroBlogClient.ChatWindow"
        x:Name="mainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:MicroBlogClient" 
        ResizeMode="CanResizeWithGrip"
        xmlns:controls="clr-namespace:Rabbit.Controls;assembly=Rabbit.Controls"
        xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d" Icon="/Resources/logo.ico" Background="{x:Null}" FontFamily="Microsoft YaHei,Sim Sun"
        WindowStartupLocation="CenterScreen" Title="{StaticResource AppTitle}"
        Opacity="{Binding CurrentUser.UserSettings.MainWindowOpacity}"
        Closing="mainWindow_Closing"
        WindowStyle="None" AllowsTransparency="True" Height="435" Width="550" MinHeight="200" MinWidth="300"
        d:DesignHeight="435" d:DesignWidth="550">

    <Border Style="{DynamicResource MainWindowBorder}" x:Name="MainBorder">
        <Border CornerRadius="5" BorderThickness="1">
            <!--main content starts from here-->
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="70"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <ContentControl MouseDoubleClick="ContentControl_PreviewMouseDoubleClick"
                            PreviewMouseLeftButtonDown="Window_PreviewMouseDown">
                    <Grid Grid.Row="0">
                        <Canvas Height="15" Grid.Row="0" VerticalAlignment="Top" Opacity="0.3" Background="{DynamicResource WindowTitleBackground}" />
                        <Canvas Height="32" Grid.Row="0" Background="{DynamicResource TitleBarLeftCornerHighlight}"/>
                        <!--Title Bar started-->
                        <Border BorderBrush="{DynamicResource WindowTitleBarInnerBorder}" CornerRadius="5,5,0,0" Margin="0" BorderThickness="1,1,0,0">
                            <Grid  Grid.Row="0" Margin="5,3,5,0">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <StackPanel  Orientation="Horizontal">
                                    <Border HorizontalAlignment="Left" Margin="5,5,0,10" Style="{StaticResource HeadPictureBorderStyle}">
                                        <Image Stretch="Fill"  Source="{Binding CurrentUser.ProfileImageUrl,Converter={StaticResource ImageConverter}}" 
                                    VerticalAlignment="Center"
                                    HorizontalAlignment="Center" 
                                   Height="48" Width="48"/>
                                    </Border>
                                    <StackPanel Margin="5">
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock  Opacity="0.9"
                                                Text="{Binding CurrentUser.ScreenName,FallbackValue=韩现龙}" Style="{DynamicResource AppTitleStyle}" />
                                            <TextBlock Margin="5,0,0,0" Text="{Binding Status,StringFormat=({0}),FallbackValue=他没用过微兔}" FontWeight="Bold" Foreground="{StaticResource AppTitleColorBrush}"/>
                                        </StackPanel>
                                        <TextBox BorderThickness="0" Opacity="0.9"
                                                 MaxWidth="400" 
                                                 IsReadOnly="True"
                                                 IsReadOnlyCaretVisible="True" 
                                                 Foreground="{DynamicResource AppTitleColorBrush}" Text="{Binding CurrentUser.Description,FallbackValue=这是这哥们的个性描述}" Background="{x:Null}"/>
                                    </StackPanel>
                                </StackPanel>
                                <StackPanel Grid.Column="1" VerticalAlignment="Top" Orientation="Horizontal">
                                    <Button Style="{DynamicResource WindowTitleBarButtonStyle}" ToolTip="最小化" Click="btnTitleBarMin_Click">
                                        <controls:ImageEx Source="{DynamicResource MinButton}"    Width="14" Height="12" Stretch="Uniform"/>
                                    </Button>
                                    <Button Style="{DynamicResource WindowTitleBarButtonStyle}" ToolTip="最大化"  Click="btnTitleBarMaximze_Click">
                                        <controls:ImageEx Source="{DynamicResource MaxButton}"  Width="14" Height="12" Stretch="Uniform"/>
                                    </Button>
                                    <Button Style="{DynamicResource WindowTitleBarButtonStyle}" ToolTip="关闭"  Click="btnTitleBarClose_Click">
                                        <controls:ImageEx Source="{DynamicResource CloseButton}" Width="14" Height="12"  Stretch="Uniform"/>
                                    </Button>
                                </StackPanel>
                            </Grid>
                        </Border>
                    </Grid>
                </ContentControl>

                <Border CornerRadius="5" Background="White" Grid.Row="1">
                    <Grid>
                        <!--<Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="80"/>
                        </Grid.ColumnDefinitions>-->
                        <Grid.RowDefinitions>
                            <RowDefinition Height=".6*"/>
                            <RowDefinition Height=".2*"/>
                            <RowDefinition Height="40"/>
                        </Grid.RowDefinitions>
                        <controls:RichTextBoxEx x:Name="rtbChatRecord"
                                                ScrollViewer.VerticalScrollBarVisibility="Auto"
                                                IsReadOnly="True"
                                                IsReadOnlyCaretVisible="True"/>
                        <TextBox Grid.Row="1" TextWrapping="Wrap" Text="{Binding Message,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                                 x:Name="txtMessage" MaxLength="140"  PreviewKeyDown="txtMessage_PreviewKeyDown"
                                 BorderThickness="0,1,0,0"/>
                        <Canvas Grid.Row="2" Margin="20,5,20,0" >
                            <TextBlock Canvas.Top="10"
                                         Text="{Binding Ad,FallbackValue=微兔2.0，您的私人客户端}"
                                         />
                            <TextBlock Canvas.Left="300" Canvas.Top="10"
                                Text="{Binding ErrorMessage,FallbackValue=错误信息}"/>
                            <Button Content="发送" Canvas.Right="0"
                                    Cursor="Arrow"
                                    x:Name="btnSendMessage"
                                    Click="btnSendMessage_Click"
                                    Height="30" Width="80"/>
                        </Canvas>
                    </Grid>
                </Border>
            </Grid>
        </Border>
    </Border>
</Window>
